<?php
session_start();

if (!isset($_SESSION['isLogged'])) {
    header('Location: index.php');
}
$now=time();
  if(isset($_SESSION['isLogged']) && ($now>$_SESSION['expired'])){
    session_unset();
    session_destroy();
    header('Location: index.php');
  }
?>
<div class="panel panel-primary">
    <div class="wm-loader in" style="display:none;" id="loader"><b></b><i></i></div>
    <div class="panel-heading">
        <h3>Data User</h3>
    </div>
    <div class="panel-body">
    <?php
    if($_SESSION['id_kewenangan']=="1" || $_SESSION['id_kewenangan']=="2"){

    ?>
    <div id="div_user">
        <form method="post" id="frm_cari" role="form" class="form-inline">
            <div class="form-group">
                <input type="text" max="18"  class="form-control" id="nip_cari" placeholder="Masukkan NIP">
            </div>
            <button type="submit" class="btn btn-default" id="btn_cari">Cari</button>
        </form>
    </div>
    <?php
        }
    ?>
        <table cellpadding="0" cellspacing="0" border="0" class="datatable table table-striped table-bordered col-lg-offset-0" id="list_users">
            <thead>
                <tr>
                    <th>NIP</th>
                    <th>Kewenangan</th>
                    <th>Status Aktif</th>
                    <!-- <th>Hapus</th> -->
                    <th>Ubah</th>
                    <th>Aktifasi</th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
        <!-- <a data-toggle="modal" href="#myModal" class="btn btn-primary btn-sm" onclick="clear_input()">Rekam User</a> -->
    </div>
</div>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true" onclick="clear_input()">&times;</button>
                <h4 class="modal-title" id="judul_modal">Perekaman User</h4>
            </div>
            <div class="modal-body">
                <div>
                <div style="float: left;">
                    <form role="form" id="rekam_frm" method="post">
                        <input type="hidden" class="form-control" id="id_user">
                        <div class="form-group">
                            <label for="nip">NIP</label>
                            <input type="text" max="18"  class="form-control" id="nip" placeholder="Masukkan NIP">
                        </div>
                        <div class="form-group">
                            <label for="password">Password</label>
                            <input type="password" class="form-control" id="password" placeholder="Password">
                        </div>
                        <div class="form-group">
                            <label for="password2">Ulangi Password</label>
                            <input type="password" class="form-control" id="password2" placeholder="Password">
                        </div>
                        <!-- <div class="form-group" style="display: none;" id="div_kanwil">
                            <label for="kanwil">Kanwil</label>
                            <select  id="kanwil" name="kanwil" class="form-control">
                            </select>
                        </div> -->
                        <div class="form-group" style="display:none;">
                            <label for="level">Kewenangan</label>
                            <select class="form-control" id="kewenangan" name="kewenangan">
                            </select>
                        </div>
                        <button type="submit" class="btn btn-default" data-dismiss="modal" onclick="reload_list_user()">Batal</button>
                        <button type="submit" class="btn btn-default" id="btn_simpan">Simpan</button>
                        <button type="submit" class="btn btn-default" id="btn_simpan_ubah">Simpan Perubahan</button>
                    </form>
                </div>
                <div id="biodata" style="float:right; display: none;">
                    <table id="data_pegawai" class="table-condensed table-bordered table-hover">
                        <thead>
                        <th colspan="2" style="text-align: center;">Biodata</th>
                        </thead>
                        <tr>
                            <th>NIP</th>
                            <td id="nip_td"></td>
                        </tr>
                        <tr>
                            <th>Nama</th>
                            <td id="nama"></td>
                        </tr>
                        <tr>
                            <th>Golongan</th>
                            <td id="gol"></td>
                        </tr>
                        <tr>
                            <th>Jabatan</th>
                            <td id="eselon"></td>
                        </tr>
                    </table>
                </div>
            </div>
            </div>
            <div class="modal-footer">
                <div id="error" class="alert alert-danger">...</div>
                <div id="success" class="alert alert-success">...</div>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<div class="modal fade" id="myModalPIC" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true" onclick="clear_input()">&times;</button>
                <h4 class="modal-title" id="judul_modal">Perekaman User</h4>
            </div>
            <div class="modal-body">
                <div>
                <div id="biodata">
                    <table id="data_pegawai" class="table-condensed table-bordered table-hover">
                        <thead>
                        <th colspan="2" style="text-align: center;">Biodata</th>
                        </thead>
                        <tr>
                            <th>NIP</th>
                            <td id="nip_td2"></td>
                        </tr>
                        <tr>
                            <th>Nama</th>
                            <td id="nama2"></td>
                        </tr>
                        <tr>
                            <th>Golongan</th>
                            <td id="gol2"></td>
                        </tr>
                    </table>
                </div>
            </div>
            <form role="form" id="pic_frm" method="post">
            <input type="hidden" class="form-control" id="id_user2">
            <div class="form-group">
                <label for="level">Kewenangan</label>
                <select class="form-control" id="kewenangan_pic" name="kewenangan_pic">
                </select>
            </div>
            <button type="submit" class="btn btn-default" data-dismiss="modal" onclick="reload_list_user()">Batal</button>
            <button type="submit" class="btn btn-default" id="btn_simpan_pic">Simpan</button>
        </form>
            </div>
            <div class="modal-footer">
                <div id="error" class="alert alert-danger">...</div>
                <div id="success" class="alert alert-success">...</div>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<script type="text/javascript" src="js/daftar.js" ></script>